package cn.myfirefly.moming.portal.dao;

import java.util.List;

import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import cn.myfirefly.moming.portal.entity.MMRoleFunction;
import cn.myfirefly.core.BaseDao;

@Repository
public class RoleFunctionDao extends BaseDao<MMRoleFunction>{
	@Autowired
	private SessionFactory sessionFactory;
	
	@SuppressWarnings("unchecked")
	public MMRoleFunction get(Integer roleSn, Integer funSn) {
		Session session = sessionFactory.getCurrentSession();
		Query query = session.createQuery(" from MMRoleFunction where roleSn = ? and funSn = ? " );
		query.setInteger(0, roleSn);
		query.setInteger(1, funSn);
		List<MMRoleFunction> list = query.list();
		MMRoleFunction roleFun = null;
		if (list != null && list.size() > 0) {
			roleFun = list.get(0);
		}
		return roleFun;
	}
	
}
